<form class="layui-form seller-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-3" style="width: 180px;">
                <select name="bank_type" lay-verify="" >
                    <option value="">银行类型</option>
                    <option value="1">Comdata</option>
                    <option value="3">Connexpay</option>
                </select>
            </div>
        </div>
        <div class="layui-inline" style="padding-left: 5px;width: 150px;">
            <select name="tran_status" >
                <option value="">Select Status</option>
                <option value="AUTHORIZATION">AUTHORIZATION</option>
                <option value="POST">POST</option>
                <option value="CREDIT">CREDIT</option>
                <option value="DECLINE">DECLINE</option>
            </select>
        </div>
        <div class="layui-inline" style="padding-left: 5px;">
            <input type="text" name="card_num" lay-verify="title" placeholder="Card Num" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-inline">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="*"><i class="iconfont icon-chaxun"></i>Search</button>
            </div>
        </div>
    </div>
</form>
<div class="table-body">
    <table id="balanceTable" lay-filter="balanceTable"></table>
</div>
<script>
    layui.use(['form', 'laydate', 'table',], function () {
        var laydate = layui.laydate,
            form = layui.form,
            table = layui.table; //表格
        //时间插件
        laydate.render({
            elem: '#datetime',
            range: '_',
            format: 'yyyy-MM-dd'
        });
        table.render({
            elem: '#balanceTable',
            height: 'full-99',
            cellMinWidth: '80',
            totalRow: true,
            method: 'post',
            url: "{:url('Cards/cardTranNew')}",
            id: 'balanceTable',
            //where:{tran_token : $('#tran_token').val()},
            toolbar: '#toolbar', //开启头部工具栏，并为其绑定左侧模板
            defaultToolbar: ['filter', 'exports'],
            cols: [[
                { type: 'numbers'},
                { field: 'mcc', align: 'center', title: 'card_token',width: 200},
                { field: 'card_num', align: 'center', title: 'card_num',width: 200},
                { field: 'ctime_real', align: 'center', title: 'cardStatus',width: 100},
                { field: 'tran_status', align: 'center', title: 'tran_token',width: 150,
                    templet:function (d) {
                        const type = d.tran_status;
                        var color = '';
                        if(type == 'DECLINE'){
                            color = 'red';
                        }else if(type == 'POST'){
                            color = 'green';
                        }else{
                            color = '#d39e00';
                        }
                        return "<span style='color:" + color + ";font-weight:bold'>" + type + "</span>"
                    },
                    totalRowText:'Total:'},
                { field: 'amount_auth',  align: 'right', title: '预扣款($)',width: 120,
                    style:'color:#FF5722;font-weight:bold',totalRow: true},
                { field: 'ctime', align: 'center', title: '交易时间',width: 170},
                { field: 'amount_post',  align: 'right', title: '预扣款($)',width: 120,
                    style:'color:#FF5722;font-weight:bold',totalRow: true},
                { field: 'utime', align: 'center', title: '结算时间',width: 170},
                { field: 'shopping',  align: 'left', title: '商家',width: 200},
                { field: 'app_code',  align: 'left', title: 'AppCode',width: 90},
                { field: 'desc',  align: 'left', title: '拒付原因',width: 200},
                { field: 'idMatchNumber', align: 'center', title: 'ApiError',width: 300},

            ]],
            page: true,
            limit: 20,
            limits: [20, 50, 100 ,500 ,1000],
        });
        form.on('submit(*)', function (data) {
            layui.table.reload('balanceTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>